package com.cctc.rds.raft.demo.log.commit.statemachine.impl;

import com.cctc.rds.raft.core.log.Log;
import com.cctc.rds.raft.core.log.commit.statemachine.StateMachine;

import java.nio.charset.StandardCharsets;

public class PrintCommandStateMachine implements StateMachine {
    @Override
    public boolean apply(Log commitLog) {
        byte[] command = commitLog.getCommand();
        String cmd = new String(command, StandardCharsets.UTF_8);
        System.out.println("状态机应用了一条命令：" + cmd);
        return true;
    }
}
